/**
 * Author:   YASUO
 * Date:     2018/7/13 14:57
 * Description:
 */
package com.rljk.common.consts;

import com.rljk.common.result.CodeMsg;
import com.rljk.exception.GlobalException;

/***
 * 订单状态常量订单状态:0-已取消-1-待付款，2-待发货，3-待收货，4-待评价，5-交易成功，6-退款售后
 */
public enum OrderEnum {

    CANCEL(0,"已取消"),
    WAIT_PAY(1,"待付款"),
    WAIT_DELIVER_GOOD(2,"待发货"),
    WAIT_RECIEVE_GOOD(3,"待收货"),
    WAIT_EVALUATE(4,"待评价"),
    FINISH(5,"交易成功"),
    FEFUND(6,"退款售后")
    ;

    private int code;
    private String name;

    OrderEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }


    public static String getName(int code) {
        for (OrderEnum c : OrderEnum.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        throw new GlobalException(CodeMsg.ENUM_NOT_FIND);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

}
